<template>
    <div class="itemPage">
        <div class="article-item van-hairline--bottom" v-for="item in list" :key="item.art_id">
          <p class="title van-multi-ellipsis--l2" :class="{w66:item.cover.type === 1}">{{ item.title }}</p>
          <img v-show="item.cover.type" class="img" v-for="(img , index) in item.cover.images" :key="index" :src="img" alt="">
          <div class="info">
              <span>小兵张嘎</span>
              <span>17评论</span>
              <span>1天前</span>
              <geek-icon name="esay-close"></geek-icon>
          </div>
  </div>
  </div>
</template>

<script>
import geekIcon from '@/components/geek-icon.vue'
import axios from 'axios'
export default {
  data () {
    return {
      list: []
    }
  },
  props: {
    id: {
      type: Number,
      required: true
    }
  },
  components: { geekIcon },
  name: 'ArticleItem',
  async created () {
    const res = await axios.get('http://toutiao.itheima.net/v1_0/articles', {
      params: {
        channel_id: this.id,
        timestamp: new Date()
      }

    })
    console.log(res.data.data.results)
    this.list = res.data.data.results
  }
}
</script>
<style scoped lang="less">
.itemPage{
  height: 100%;
  overflow-y: auto;
  padding: 0 16px;
}
.article-item {
  padding: 15px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  .title {
    width: 100%;
    margin: 0;
    line-height: 22px;
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
    max-height: 44px;
    &.w66 {
      width: 66%;
    }
  }
  .img {
    width: 112px;
    height: 74px;
    border-radius: 4px;
    margin-bottom: 8px;
  }
  .info {
    width: 100%;
    color: #A5A6AB;
    font-size: 12px;
    position: relative;
    span {
      margin-right: 12px;
    }
    .geek-icon {
      float: right;
      font-size: 14px;
    }
  }
}
</style>
